/*
 * Pidgin/libpurple Chime client plugin
 *
 * Copyright © 2020 Amazon.com, Inc. or its affiliates.
 *
 * Author: David Woodhouse <dwmw2@infradead.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

#include "dbus.h"
#include "chime.h"

#include <string.h>

/* Generated by libpurple/dbus-analyze-functions.py.  Do not edit! */
static DBusMessage*
chime_add_joinable_meeting_DBUS(DBusMessage *message_DBUS, DBusError *error_DBUS) {
	DBusMessage *reply_DBUS;
	dbus_int32_t account_ID;
	PurpleAccount *account;
	const char *pin;
	dbus_message_get_args(message_DBUS, error_DBUS, DBUS_TYPE_INT32, &account_ID, DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID);
	CHECK_ERROR(error_DBUS);
	PURPLE_DBUS_ID_TO_POINTER(account, account_ID, PurpleAccount, error_DBUS);
	if (!account || !account->protocol_id || strcmp(account->protocol_id, "prpl-chime")) {
		dbus_set_error(error_DBUS, "im.pidgin.purple.InvalidHandle",
			       "PurpleAccount object with ID = %i is not a Chime account", account_ID);
		return NULL;
	}
	pin = (pin && pin[0]) ? pin : NULL;
	chime_add_joinable_meeting(account, pin);
	reply_DBUS = dbus_message_new_method_return (message_DBUS);
	dbus_message_append_args(reply_DBUS, DBUS_TYPE_INVALID);
	return reply_DBUS;
}

PurpleDBusBinding chime_purple_dbus_bindings[] = {
	{"ChimeAddJoinableMeeting", "in\0i\0account\0in\0s\0pin\0", chime_add_joinable_meeting_DBUS},
	{NULL, NULL, NULL}
};
